﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace IPMS.Models
{
    public class ProjectModel
    {
        private DataContextDataContext dataContext;
        public ProjectModel()
        {
            this.dataContext = new DataContextDataContext();
        }
        public List<Project> GetListProject(int userID)
        {
            try
            {
                int count = this.dataContext.GetListProject(userID).ToList().Count;
                return this.dataContext.GetListProject(userID).ToList();
            }
            catch (Exception ex)
            {
                return null;
            }
        }
        /// <summary>
        /// Kiểm tra quyền điều khiển project của user
        /// </summary>
        /// <param name="projectID"></param>
        /// <param name="userID"></param>
        /// <returns></returns>
        public bool CheckUserPermissionOnProject(int projectID, int userID)
        {
            return this.dataContext.CheckUserProject(projectID, userID).Value;
        }
        public Project GetProjectByID(int id)
        {
            return this.dataContext.GetProjectByID(id).FirstOrDefault();
        }
    }
}